<html>
<head>
	<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8">
	<title>Jsswing FlowLayout Demo</title>
	<link rel="stylesheet" type="text/css" href="ext2/resources/css/ext-all.css" />
	<script type="text/javascript" src="ext2/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="ext2/ext-core-debug.js"></script>	
		
	<script type="text/javascript" src="js/jsswing.js"></script>
	<script>
	
	jsw.ROOT_DIR='.';
	//jsw.debugEnabled=true;
	var MyApi = function(){
		MyApi.superclass.constructor.call(this,new jsw.BoxLayout(this,jsw.BoxLayout.X_AXIS));
		this.init();
	};
	Ext.extend(MyApi, jsw.JPanel,{
			init:function(){
				var classlist = new jsw.JPanel();
				classlist.setBackgroundImg(jsw.ROOT_DIR+"/js/img/ui/tran.png");
			
				var scrp1 = new jsw.ScrollPane(classlist);	
				scrp1.setBorder(new jsw.border.ShadowBorder());
				scrp1.setBackgroundImg(jsw.ROOT_DIR+"/js/img/ui/tran.png");
				var prefs=scrp1.getPreferredSize();
				scrp1.setMaximumSize({width:290,height:Integer.MAX_VALUE});
				scrp1.setPreferredSize({width:290,height:Integer.MAX_VALUE});
				this.add(scrp1);
				
				var methodlist = new jsw.HTMLPane();
				scrp2 = new jsw.ScrollPane(methodlist);	
				scrp2.setBorder(new jsw.border.ShadowBorder());
				scrp2.setBackgroundImg(jsw.ROOT_DIR+"/js/img/ui/tran.png");
				this.add(scrp2);
				
				this.listClasses(jsw,classlist);
			},
			listClasses:function(packageRef,container){
				container.setLayout(new jsw.BoxLayout(container,jsw.BoxLayout.Y_AXIS));
				container.setForeground("white");
				for(var i in packageRef){
					if(typeof(packageRef[i])=="function"){
						var firstLetter = i.substring(0,1);
						if(firstLetter.toUpperCase() == firstLetter){
							//this is a class
							var lb = new jsw.JLabel(i);
							var prefs = lb.getPreferredSize();
							lb.setAlignmentX(jsw.JComponent.LEFT_ALIGNMENT);
							lb.setMaximumSize(prefs);
							lb.addMouseListener(this);
							lb.setCursor("pointer");
							//lb.setForeground("white");
							//lb.setOpaque(true);
							//lb.setBackground("black");
							container.add(lb);
						}else{
							//a function
							var lb = new jsw.JLabel(i);
							var prefs = lb.getPreferredSize();
							lb.setAlignmentX(jsw.JComponent.LEFT_ALIGNMENT);
							lb.setMaximumSize(prefs);
							lb.setForeground("green");
							//lb.setBackground("black");
							container.add(lb);
						}
					}
					else if(typeof(packageRef[i])=="object"){
						if(i.toLowerCase()==i){
							//this is a sub package.
							var lb = new jsw.JLabel(i+"/");
							var prefs = lb.getPreferredSize();
							lb.setAlignmentX(jsw.JComponent.LEFT_ALIGNMENT);
							lb.setMaximumSize(prefs);
							lb.setForeground("#000000");
							
							container.add(lb);
							
							var panel = new jsw.JPanel();
							panel.setAlignmentX(jsw.JComponent.LEFT_ALIGNMENT);
							panel.setLayout(new jsw.BoxLayout(panel,jsw.BoxLayout.X_AXIS));
							panel.setBorder(new jsw.border.ShadowBorder());
							panel.setBackgroundImg(jsw.ROOT_DIR+"/js/img/ui/tran.png");
							panel.add(jsw.Box.createRigidArea({width:10,height:20}));
							
							var subPanel=new jsw.JPanel();
							panel.add(subPanel);
							this.listClasses(packageRef[i],subPanel);
							container.add(panel);
						}else if(i.toUpperCase()==i){
							//static field
						}else{
							//this is a class maybe only contains static methods and fields
							var lb = new jsw.JLabel("<b>"+i+"</b>");
							var prefs = lb.getPreferredSize();
							lb.setAlignmentX(jsw.JComponent.LEFT_ALIGNMENT);
							lb.setMaximumSize(prefs);
							lb.addMouseListener(this);
							lb.setCursor("hand");
							//lb.setForeground("white");
							container.add(lb);
						}
						//var panel = new jsw.JPanel();
					}
				}
			},
			mouseClicked:function(mouseEvent){
			
			},
			mousePressed:function(mouseEvent){},
			mouseReleased:function(mouseEvent){},
			mouseEntered:function(mouseEvent){
				var s=mouseEvent.getSource();
				s.setOpaque(true);
				s.setForeground("black");
				s.setBackground("white");
			},
			mouseExited:function(mouseEvent){
				var s=mouseEvent.getSource();
				s.setOpaque(false);
				s.setForeground("");
				s.setBackground("");
			}
	});
	Ext.onReady(
		function(){
			
			var doc = jsw.BrowserDocument.getInstance();
			
			doc.add(new MyApi());
			
			doc.setBackgroundImg(jsw.ROOT_DIR+"/js/img/ui/wallpaper.jpg");
			doc.setLayout(new jsw.BoxLayout(doc,jsw.BoxLayout.X_AXIS));
			doc.setVisible(true);//set everything visible

		});
	</script>
</head>
<body>

</body>
</html>